using Castle.Windsor;
using Mestedur.Models.WindsorModules;

namespace Mestedur.Models
{
    public static class ContainerFactory
    {
        private static IWindsorContainer container;
        private static readonly object SyncObject = new object();

        public static IWindsorContainer Current()
        {
            if (container == null)
            {
                lock (SyncObject)
                {
                    if (container == null)
                    {
                        container = new WindsorContainer();
                        container.Install(new HibernateInstaller());
                        container.Install(new MembershipInstaller());
                        container.Install(new RepositoryInstaller());
                        container.Install(new UnitOfWorkInstaller());
                        container.Install(new ServiceInstaller());
                    }
                }
            }
            return container;
        }
        
    }
}